﻿using System;
using AnjLab.FX.Patterns.Generic;
using AnjLab.FX.Sys;
using AnjLab.SyncIT.Core.Data.DotProject;
using AnjLab.SyncIT.Core.Data.GoogleCode;
using AnjLab.SyncIT.Core.Data.Trac;

namespace AnjLab.SyncIT.Core.Api
{
    public class Provider
    {
        static Provider() {
            Register("trac", new TracProvider());
            Register("googlecode", new GoogleCodeProvider());
            Register("dotProject", new DotProjectProvider());
            Register("1C:Enterprise", new Data._1C.Provider());
        }

        static private readonly KeyedFactory<string, Provider> _providers = new KeyedFactory<string, Provider>();

        public static void Register(string key, Provider provider) {
            _providers.RegisterImmutable(key, provider);
        }

        public virtual bool HasPassword {
            get {
                return true;
            }
        }

        public virtual string Icon {
            get {
                return "";
            }
        }

        public virtual bool MayChacheTaskDao
        {
            get { return true; }
        }

        public static Provider Get(string key) {
            Guard.ArgumentNotNull("key", key);
            return _providers.Create(key);
        }

        public virtual ISourceTaskDao CreateTaskDao(Source source) {
            throw new NotImplementedException();
        }

        public string GetTitle(Source source) {
            return source.ProjectBase;
        }

        public virtual string GetMyTasksUrl(Source source) {
            throw new NotImplementedException();
        }

        public virtual string GetActiveTasksUrl(Source source) {
            throw new NotImplementedException();
        }

        public virtual string GetProjectBaseHint(Source source)
        {
            return "Specify project location";
        }

        public virtual string GetUserNameHint(Source source)
        {
            return "Your account login";
        }

        public virtual string GetPasswordHint(Source source)
        {
            return "Password for your account";
        }

        public virtual string GetOutlookPrefixHint(Source source)
        {
            return "Prefix for new task's subject.\nThe subject will look like: \"prefix #ID: Summary\"";
        }

        public virtual string GetOutlookCategoryHint(Source source)
        {
            return "Select Outlook categories for synchronized tasks";
        }

        public virtual string DefaultOutlookItemBodyTemplate
        {
            get { return string.Empty;  }
        }
    }
}
